import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_one/class/utils/Utils.dart';

/////////////////////////////////////////////////////
//MARK: - 主题信息配置
/////////////////////////////////////////////////////
/// - app 主题色
// ignore: non_constant_identifier_names
Color get K_APP_TINT_COLOR => Utils.shareInstance.hexToInt(0xFF6C3F);

/// - progress 显示持续时间(单位：秒)
const Duration K_APP_PROGRESS_HUD = Duration(seconds: 3);

/// - 顶部导航背景色
// ignore: non_constant_identifier_names
Color get K_APP_NAVIGATION_BACKGROUND_COLOR =>
    Utils.shareInstance.hexToInt(0xF5F5F5,alpha: 0.01);

/// - app页面背景色
// ignore: non_constant_identifier_names
Color get K_APP_BACKGROUND_COLOR => Utils.shareInstance.hexToInt(0xFFFFFF);

/// - app Name
const String K_APP_NAME = "FlutterDemo";

/// - 视图阴影颜色
// ignore: non_constant_identifier_names
Color get K_APP_VIEW_SHADOW_COLOR =>
    Utils.shareInstance.hexToInt(0x919191, alpha: 0.29);

/// - 未启用视图颜色
// ignore: non_constant_identifier_names
Color get K_APP_VIEW_UNABLE_COLOR => Utils.shareInstance.hexToInt(0xc5c5c5);

/// - 视图阴影透明度
const K_APP_VIEW_CELL_SHADOW_OPACITY = 0.3;

/////////////////////////////////////////////////////
//MARK: - 服务端信息配置
/////////////////////////////////////////////////////
/// true 正式版(上架商店需要改为 true) false 测试版
const bool K_APP_IS_PRODUCT = false;

/// app接口
const K_APP_REQUEST_HOST = K_APP_IS_PRODUCT
    ? "https://cloud.dylzcx.com/prod-api/v3/"
    : "https://cloud.dylzcx.com/prod-api/v3/";

/// 接口请求状态键
const K_API_RESULT_CODE = "status";
const K_API_RESULT_CODE2 = "code";

/// 接口返回的描述信息键
const K_API_RESULT_MESSAGE = "msg";

/// 接口返回信息键
const K_API_RESULT_DATA = "data";
const K_API_RESULT_DATA2 = "rows";

/// 请求超时时间（单位：秒）
const Duration K_APP_REQUEST_TIME_OUT = Duration(seconds: 15);

/// 网络请求的支持类型
const Set<String> K_APP_ACCEPTABLE_CONTENT_TYPES = {
  "application/json",
  "text/json",
  "text/javascript",
  "text/plain",
  "text/html",
  "application/x-www-form-urlencoded"
};

/// 页面数据大小
const int K_APP_PAGE_SIZE = 20;

/// 网络请求状态判断(0 成功)
// ignore: non_constant_identifier_names
bool K_API_IS_OK(Object rs) {
  final int? _r = rs as int;
  if (_r != null && _r == 0) {
    return true;
  }

  return false;
}
